#!/bin/bash
#ck单机版启动命令,在 7.0.144.11 机器上,每次启动需要将后面的序号依次+1，例如 02,变成03
export DOCKER_NAME=docker_ck01
sudo docker run  --name $DOCKER_NAME -d --ulimit nofile=262144:262144  -v /etc/localtime:/etc/localtime:ro  \
-v /workdir/clickhouse/clickhouse/clickhouse-server-config:/etc/clickhouse-server \
-v /workdir/clickhouse/clickhouse/clickhouse-server-log:/var/log/clickhouse-server \
-v /workdir/clickhouse/clickhouse/data:/var/lib/clickhouse/data \
-v /workdir/clickhouse/clickhouse/metadata:/var/lib/clickhouse/metadata  -p 8123:8123 -p 9000:9000 -it centos-clickhouse:v18.10 /bin/bash
#查看docker ck是否启动
sudo docker ps
#进入docker
sudo docker exec -it $DOCKER_NAME /bin/bash
/etc/rc.d/init.d/clickhouse-server start
#停止ck单机版
sudo docker stop $DOCKER_NAME
#启动mysql单机版
export MYSQL_NAME=mysql01
docker run --name=$MYSQL_NAME --privileged=true -p 3306:3306 -v /etc/localtime:/etc/localtime:ro -v /dockerData/mysql/datadir/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=hadoop -d mysql_bpm_os6.9:6.9 docker-entrypoint.sh mysqld
####################################################################################################################
#ck集群的启动命令,在 7.0.144.113,7.0.144.121,7.0.144.124,7.0.144.134 ,4台机器上
#以bpm用户登录并执行,每台机器都需要先登录bpm用户，不许用root操作
su bpm
#ck启动命令
sudo /opt/clickhouse/bin/clickhouse-server1.sh start
#ck停止命令
sudo /opt/clickhouse/bin/clickhouse-server1.sh stop

#mysql主启动命令,在 7.0.144.124 机器上,每次启动需要将后面的序号依次+1，例如 02,变成03
export MYSQL_NAME=mysql_master03
sudo docker run --name $MYSQL_NAME -v /etc/localtime:/etc/localtime:ro -v /etc/mysql-custom:/etc/mysql/conf.d \
-v /data/mysql:/var/lib/mysql -v /data/log/mysql:/var/log -e MYSQL_ROOT_PASSWORD=hadoop \
-p 3306:3306 -p 13388:13388 -d mysql:5.7 mysqld --server-id=161733388
#停止
sudo docker stop $MYSQL_NAME
#mysql备启动命令,在7.0.144.134机器上,每次启动需要将后面的序号依次+1，例如 10,变成11
export MYSQL_NAME=mysql_slave10
sudo docker run --name $MYSQL_NAME --net=host -v /etc/localtime:/etc/localtime:ro -v /etc/mysql-custom:/etc/mysql/conf.d \
-v /data/mysql:/var/lib/mysql -v /data/log/mysql:/var/log -e MYSQL_ROOT_PASSWORD=hadoop \
-p 3306:3306 -p 13388:13388 -d mysql:5.7 mysqld --server-id=161833388
#停止
sudo docker stop $MYSQL_NAME
#zookeeper启动命令,在 7.0.144.113,7.0.144.121,7.0.144.124,7.0.144.134 ,4台机器上执行
/opt/zookeeper-3.5.3-beta/bin/zkServer.sh start
#zookeeper停止命令,在 7.0.144.113,7.0.144.121,7.0.144.124,7.0.144.134 ,4台机器上执行
/opt/zookeeper-3.5.3-beta/bin/zkServer.sh stop
#zookeeper 客户端连接
/opt/zookeeper-3.5.3-beta/bin/zkCli.sh
#datax的启动脚本 7.0.144.113 机器
/opt/datax/entry/szsbpm/run_ora2intf.sh /opt/datax/job/szsbpm/t0/intf_zxyh_df_loaninfo_t0.json 20181220
#虚拟ip切换的docker
#在 7.0.144.124 上
export VIP='7.0.144.186'
export KEEPALIVED_NAME=keep05
cd /data/install
sudo docker run --name=$KEEPALIVED_NAME --net=host --privileged=true --volume=$PWD/:/ka-data/scripts/ -d solnetcloud/keepalived:1.2.7 \
--master --override-check check-mysql-status.sh --enable-check --auth-pass pass --vrid 52 ens160 102 $VIP/24/ens160
#停止
sudo docker stop $KEEPALIVED_NAME
#在7.0.144.134上
export KEEPALIVED_NAME=keep05
export VIP='7.0.144.186'
cd /data/install
sudo docker run --name=$KEEPALIVED_NAME --net=host --privileged=true --volume=$PWD/:/ka-data/scripts/ -d solnetcloud/keepalived:1.2.7 \
--override-check check-mysql-status.sh --enable-check --auth-pass pass --vrid 52 ens160 99 $VIP/24/ens160
#停止
sudo docker stop $KEEPALIVED_NAME
